package com.zhoushihao.class0818;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = sc.nextInt();
        HighDangerArea area = new HighDangerArea(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());

        List<List<Person>> persons = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            List<Person> person_t = new ArrayList<>();
            for (int j = 0; j < t; j++) {
                person_t.add(new Person(sc.nextInt(), sc.nextInt()));
            }
            persons.add(person_t);
        }

        int count_s = 0;
        int count_l = 0;
        for (List<Person> person : persons) {
            int count_tmp = 0;
            int flag = 0;
            for (Person p : person) {
                if(area.isContains(p.x, p.y)) {
                    count_tmp++;
                    flag = 1;
                    if(count_tmp >= k) {
                        count_l++;
                        break;
                    }
                }else{
                    count_tmp = 0;
                }
            }
            if(flag == 1) {
                count_s++;
            }
        }

        System.out.println(count_s);
        System.out.println(count_l);
    }

}

class Person {
    int x;
    int y;

    public Person(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class HighDangerArea {
    int x_l;
    int y_d;
    int x_r;
    int y_u;

    public HighDangerArea(int x_l, int y_d, int x_r, int y_u) {
        this.x_l = x_l;
        this.y_d = y_d;
        this.x_r = x_r;
        this.y_u = y_u;
    }

    public boolean isContains(int x, int y) {
        if (x >= x_l && x <= x_r && y >= y_d && y <= y_u) {
            return true;
        }
        return false;
    }
}
